package com.yangrd.airship.upms.domain;

import com.yangrd.airship.upms.infrastructure.List2StrAttributeConverter;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * description: Role
 *
 * @author: yangrd
 * @date: 2021/6/24
 * @version: 1.0
 */
@Getter
@Setter
@Entity
@Table(name = "upms_role")
public class Role extends AbstractEntity {


    private String name;

    private String authority;

    @Column(length = 2000)
    @Convert(converter = List2StrAttributeConverter.class)
    private List<String> permissions;

    public List<String> listPermission() {
        return Objects.isNull(permissions) ? Collections.emptyList() : permissions;
    }
}
